package com.tsoj.tsojquestionservice.controller.inner;


import com.tsoj.model.po.Question;
import com.tsoj.model.po.QuestionSubmit;
import com.tsoj.tsojquestionservice.service.QuestionService;
import com.tsoj.tsojquestionservice.service.QuestionsubmitService;
import com.tsoj.tsojserviceclient.service.QuestionFeignClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 该服务仅内部调用，不是给前端的
 */
@RestController
@RequestMapping("/inner")
@Api(tags = "题目内部服务")
public class QuestionInnerController implements QuestionFeignClient {

    @Resource
    private QuestionService questionService;

    @Resource
    private QuestionsubmitService questionSubmitService;

    @GetMapping("/get/id")
    @Override
    @ApiOperation("根据id获取题目 内部")
    public Question getQuestionById(@RequestParam("questionId") long questionId) {
        return questionService.getById(questionId);
    }

    @GetMapping("/question_submit/get/id")
    @Override
    @ApiOperation("根据id获取题目提交 内部")
    public QuestionSubmit getQuestionSubmitById(@RequestParam("questionId") long questionSubmitId) {
        return questionSubmitService.getById(questionSubmitId);
    }

    @PostMapping("/question_submit/update")
    @Override
    public boolean updateQuestionSubmitById(@RequestBody QuestionSubmit questionSubmit) {
        return questionSubmitService.updateById(questionSubmit);
    }

}
